<?php

$json = array("success" => false, "msj" => "mamó");
$user = json_decode(filter_input(INPUT_POST, 'user_'));  
if($user != NULL)
{ 
    $usuario = $user[0]; 
    $query_crear = $user[1]; 
    $rols = $user[2][0];  
    $privs = $user[2][1]; 
    $Run_ = fopen("run.sql", "w+") or die("no abrió run.sql");  
    $str_run = $query_crear."\n";   
    foreach ($rols as $r)
        $str_run.= "GRANT ".$r." TO ".$usuario.";\n";
    foreach ($privs as $p)
        $str_run.= "GRANT ".$p." TO ".$usuario.";\n";
    fwrite($Run_, $str_run); 
    fclose($Run_);
    exec("cmd_.bat");
    $json['success'] = true;
}
print( json_encode($json));